package net.mikoo.seals.model;
import java.io.Serializable;
import java.util.Date;

import net.mikoo.seals.common.WebContext;

/**
 * @author huangxm
 * 
 */
public class BaseModel implements Serializable {
	
	private static final long serialVersionUID = 4979850426150980383L;

	//批量操作索引值 
	private Integer index;
	
	private Date createTime = new Date();

	private Date updateTime;
	
	private int offset = 0;
	
	private int pageSize =10;
	
	private String orderColumn;
	
	private String orderType;

	/**
	 * 
	 */
	public BaseModel() {
	}

	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public int getOffset() {
		
		if(offset <= 0){
			
			Integer currentPage = WebContext.getPage();
			if(currentPage== null){
				currentPage = 1;
			}
			offset = (currentPage -1) * pageSize;
		}
		
		
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getIndex() {
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}
	public String getOrderColumn() {
		return orderColumn;
	}
	public void setOrderColumn(String orderColumn) {
		this.orderColumn = orderColumn;
	}
	public String getOrderType() {
		return orderType;
	}
	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}

}
